package io.nads.service.impl;

import io.nads.constant.RedisConstant;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.List;

@Slf4j
@SpringBootTest
public class TTSServiceImplTestDebug {

    @Autowired
    private TTSServiceImpl ttsService;
    
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Test
    public void testClearCacheAndGetVoices() {
        // 清除Redis缓存
        String key = RedisConstant.QINIU_TTS_VOICE_KEY;
        stringRedisTemplate.delete(key);
        log.info("已清除Redis缓存: {}", key);
        
        // 重新获取音色列表（这会触发从API获取并缓存带括号的数据）
        List<String> supportedVoices = ttsService.getSupportedVoices();
        log.info("SupportedVoices (去掉括号): {}", supportedVoices);
        
        // 获取音色标签（括号内的内容）
        List<String> supportedVoiceLabels = ttsService.getSupportedVoiceLabels();
        log.info("SupportedVoiceLabels (括号内容): {}", supportedVoiceLabels);
        
        // 检查Redis中缓存的原始数据
        String cachedData = stringRedisTemplate.opsForValue().get(key);
        log.info("Redis中缓存的原始数据: {}", cachedData);
    }
}